package lumis.portal.serialization.persistency.zip;

import java.io.Closeable;
import java.io.IOException;
import java.io.OutputStream;


/**
 * {@link OutputStream} wrapper that calls back the stream's source {@link ZipDirectory} when then stream is closed.  
 * @version $Revision: 6376 $ $Date: 2007-04-10 17:55:53 -0300 (Tue, 10 Apr 2007) $
 * @since 4.0.10
 */
class ZipDirectoryOutputStream extends OutputStream
{
	private Closeable streamClosingCallback;
	private OutputStream os;

	public ZipDirectoryOutputStream(OutputStream os, Closeable streamClosingCallback)
	{
		this.os = os;
		this.streamClosingCallback = streamClosingCallback;
	}

	@Override
	public void close() throws IOException
	{
		streamClosingCallback.close();
	}

	@Override
	public void flush() throws IOException
	{
		os.flush();
	}

	@Override
	public void write(byte[] b, int off, int len) throws IOException
	{
		os.write(b, off, len);
	}

	@Override
	public void write(byte[] b) throws IOException
	{
		os.write(b);
	}

	@Override
	public void write(int b) throws IOException
	{
		os.write(b);
	}
}
